Update 13.3:
> Allows object frames to be ordered horizontally instead of vertically; to mark such objects
  use:
   object_#_horizontal_frames = 1

Update 13.2:
> Improves support for working with styles using the V_xxxx.DAT / G_xxxx.DAT naming scheme.

Update 13.1:
> Fixes the bug where "unsupported type" will display on splat pads when converting Cheapo
  styles.
> Fixes the bug where said message will not display on gravity changers.
> Fixed a bug with Single Teleporters and Two-Way Teleporters in Cheapo conversions.
> An error is displayed, and the program waits for the user to press a key, when an unrecognized
  object type is detected while converting a Cheapo style. (It won't display for object types that
  are recognized but unsupported.)

Update 13:
> Adds trigger_point_x and trigger_point_y properties for objects; these are used on two
  new object types (Two-Way Teleporters and Single Teleporters).
> Adds support for all object types in Cheapo styles, apart from gravity changers.

Update 12.1:
> Fixes an issue with receiver positions not being set properly in Cheapo convertor.
> Can handle Cheapo styles that contain objects with circular trigger areas.

Update 12:
> Adds support for PNG and GIF images. Use the same filename but with the GIF or PNG extension;
  if more than one exist, BMP has highest priority and GIF has lowest. Note that transparency
  is not supported; you must still use a transparent color as normal.
> Adds support for using extracted Cheapo styles (using Essman's extractor) as input.
> Supports graphic sets where object #1 is not a window.

Update 11:
> Supports graphic sets with up to 128 terrains and 32 objects.
> Supports graphic sets with RGB (non-palette-based) images.

Update 10:
> Fixed some inaccurate colors in the default palettes (including those used when extracting
  graphics sets).
> Trigger positions can now be set on window objects; these will be useful in a future NeoLemmix
  update.
> Added an option to save the default palettes as BMP files, rather than including copies of
  them.
> Compiled with a newer version of QB64, giving the EXE a much smaller filesize.

Update 9:
> Fixed a bug when decompiling 16-color graphic sets that were previously compiled by LemSet.
> Now supports larger-size files. Note that if either section exceeds 64KB, the resulting
  style will only be compatible with engines that support the extended format - these are
  NeoLemmix V1.20n onwards, NeoLemmix Editor V1.20n-A onwards, and CustLemmix V17 onwards.

Update 8:
> Can now decompile graphic sets.
> Now supports an option to "protect" graphic sets so they can't be decompiled; please note
  that this is a very weak protection that any semi-advanced user will be able to bypass.
  However, users advanced enough to do so will (hopefully) be respectful of your wishes.
> Fixed the spelling error where "palette" was spelt "pallete". Please note that style INIs
  must be updated to use the correct spelling; you can quickly do this by doing a Find & Replace
  with "pallete" to "palette" and using "Replace All".
> Fixed a bug where the NeoLemmix features mark would not be activated if a style used key
  frames but didn't have any non-divisible-by-4 trigger areas.

Update 7:
> LemSet now supports marking a graphic set as using the Xmas Palette. You still need to use
  palette info that corresponds to this; this is just for NeoLemmix or CustLemmix's purposes,
  so they know to use the Xmas palette for that set.
> Fixed a glitch where multi-digit output style numbers were't supported.

Update 6:
> LemSet now sets the switch to mark a set as supporting autosteel. Previously, NeoLemmix assumed
  *all* graphic sets supported it, which could cause compatibility issues on older sets.

Update 5:
> Fixed a glitch where some pieces were being marked as steel even though they shouldn't be.

Update 4:
> Now supports marking terrain pieces as steel.

Update 3:
> Now supports 32-color palettes. 32-color palette graphic sets can only display the full color range on NeoLemmix or CustLemmix (even non-Neo versions of CustLemmix support it, unlike other NeoLemmix features); other engines will downscale them to 16 colors; with the high 16 colors being mapped to the equivalent position in the low 16.
> Now supports pixel-perfect trigger areas.

Update 2:
> palette matching now works from color 15 to color 0 instead of 0 to 15. This means, if you have a duplicate between your palette and the default, it'll use your custom entry instead. This is important because DOS (but not Lemmix) will display default palette terrain but will not regard it as solid.
> INI support improved.
> Added a new command, style_number.

Update 1:
> Added compression support, no need for an external compression tool anymore.



CREDITS:
Galleon - For QB64
SMcNeill - For coding assistance
ccexplore - For Lemmings format documentation and assistance with compression algorithm

LemSet created by Namida Verasche (aka Namida / Ninjamida / Hayan Ninja).
If you like this tool, show your thanks by using it to create awesome graphic sets and levels. =P




Styles to compile should consist of the following files in the same directory as the EXE:

[name].ini              	- Style info
[name]_tXX.bmp          	- Terrain graphics
[name]_oXX.bmp           	- Object graphics
[name]_palette.bmp (optional) 	- palette

Where [name] is the same across all files. Enter this name when you run the program.
You can also do it from the command line: lemset.exe [name] (No quotes or brackets!)

If you run the program and simply press enter without entering a name, it will look for the following:

style.ini		- Style info
tXX.bmp			- Terrain graphics
oXX.bmp			- Object graphics
palette.bmp (optional)	- Palette


FORMATS:

BMP files should be saved as 24-bit uncompressed BMP files. The tool *should* be able to load any version of the BMP format, as long as it's 24-bit and uncompressed. It will NOT load BMPs that are compressed or 16-color/256-color. I'm also not sure how well it handles BMPs that are stored top-down.

Don't freak out too much about this - if you save your images in MS Paint using the "24-bit" option, they will be in the correct format for this tool.

Images may be any height, but the width must be divisible by 8. You can, of course, just add extra blank space to pad it to the correct size. Any color which is defined in the palette will be rendered as-is, while colors which are not will be rendered as transparent. If using RGB-based images instead of palette-based ones, the 8th color in the palette (counting the first one as 1) is treated as the transparent color. It should be noted that Lemmings only uses 18-bit color values, not 24-bit. Because of this, some colors which are slightly different in 24-bit will be exactly the same in 18-bit. The 18-bit values, not the 24-bit values, are used when matching pixels to the palette.

Terrain pieces should be a single graphic for each piece.

Objects should contain all frames in one image, arranged vertically in order. Therefore, the size of this image should be [width] x [height * frames]. There should be NO gap between frames.

You can define the palette either in the INI file or using a palette.bmp file. If you're using a palette.bmp file, it should be 16x1 or 32x1 (depending on the colors in the style you're creating), with each pixel representing one palette entry.

Note that Lemmings will automatically override the first 7 colors of the palette with default ones, and the 8th color with a duplicate of the 9th. Colors 9 through 16/32 may be chosen freely.

The INI file should be one value per line, with a format of [key]=[value], no quotes around the value even if it's text. It does not matter whether you include spaces on one (or both) sides of the equals sign or not. For example:

palette_type=24
palette_type =24
palette_type= 24
palette_type = 24

Any of these is acceptable.

The INI file must also have a line return at the end of the last line, otherwise the data on the last line will not be counted!

All types of line returns are supported - CF, LF, or CF+LF.
Lines that do not contain an = symbol are ignored by LemSet, so you can include comments as plain text simply by not having an = on the same line.
You no longer need to have a line break at the end of the file, and you can now have blank lines in your file.




INI File:

The INI file must contain:
- Palette info
- Information on each object
- A style number (optional)

You do not need to enter any information about terrain pieces. This is because all of their information can be derived from the image files. However, if you are creating the style for NeoLemmix, you may want to mark specific pieces as steel.

It does not matter what order the data in the INI file is in; it only matters that all of it is there. You can even mix and match different sections together, LemSet won't care.


1) Palette info

The first setting under palette_info is the palette type. This can be set to one of three values:

palette_info = 24            Uses 24-bit RGB values to define the palette
palette_info = 18            Uses 18-bit RGB values to define the palette
palette_info = bmp           Uses palette.bmp to define the palette

If palette_info is set to bmp, the graphic set's palette will be derived from palette.bmp, and no further palette information is needed in the INI file.

Otherwise, you will need to define each color. Define colors as follows:

palette_# = R,G,B

Where R, G, B are the red, green and blue values of the color. If palette_info is set to 24, you should enter values from 000 to 255. If palette_info is set to 18, you should enter values from 00 to 63 (the same values that Lemmings itself uses). Note that you must pad the values with 0s - if you are using 24-bit values, all entries should be 3 digits; if you are using 18-bit values, all entries should be 2 digits.
In fact - no matter what format you use, the program converts it to 18-bit values before processing further. The other two methods are simply included for convenience.
Just like with defining keys, it does not matter how or where you put spaces.

You must also specify whether it's a 16-color palette or a 32-color one, unless you are using a BMP:

palette_colors = 32

Colors are numbered starting at zero. The Lemmings default palette (note: this does not apply to Xmas/Holiday lemmings, only Lemmings/ONML/CustLemm) is:

palette_info = 18
palette_0 = 00,00,00
palette_1 = 16,16,56
palette_2 = 00,44,00
palette_3 = 60,52,52
palette_4 = 60,60,00
palette_5 = 56,08,08
palette_6 = 32,32,32
palette_7 = 00,00,00

or

palette_info = 24
palette_0 = 000,000,000
palette_1 = 064,064,224
palette_2 = 000,176,000
palette_3 = 240,208,208
palette_4 = 240,240,000
palette_5 = 224,032,032
palette_6 = 128,128,128
palette_7 = 000,000,000


The included defpal##.bmp files have the default palette (and empty spaces) in the correct layout for palette.bmp.


Note that you must include a palette (though it can be a 16-color one) even if using RGB-based images. This is because colors from the graphic set's palette are used by certain lemming animations, and possibly the skill panel depending on the MAIN.DAT file in use.

Speaking of which, to use RGB-based images, use the following line:

rgb_images = 1


2) Object info

You must set the following values for each object. The values listed are the defaults if you do not set anything for a specific object.

object_#_frames = 0          Number of animation frames (starting from 1, not 0).
                             If this is set to zero, the slot will be assumed to be empty.
object_#_start_frame = 0     Frame number (starting from 0) to start animation from.
object_#_trigger_left = 0    X coordinate of trigger area. Range: -3 to (width - 1).
object_#_trigger_top = -4    Y coordinate of trigger area. Range: -7 to (height - 1).
object_#_trigger_width = 4   Width of trigger area. Range: 1 to 1024.
object_#_trigger_height = 4  Height of trigger area. Range: 1 to 1024.
object_#_trigger_point_x = 0 Sets the trigger point X coordinate; this is only used on
                             two-way teleporters and single-object-teleporters.
object_#_trigger_point_y = 0 Same as above, but the Y coordinate.
object_#_trigger_type = 0    Effect of trigger area. See below for values.
object_#_preview_frame = 0   Frame number (starting from 0) to display on preview screen.
object_#_trigger_anim = 0    Sets triggered animation (otherwise, object will animate constantly).
object_#_trigger_sound = 0   Sets the sound effect played when the object is triggered. See below.
object_#_key_frame = 0       Sets the "key frame" for the object (for example, teleporters use this
                               to indicate at which frame the receiver animation should start, while
                               receivers do to indicate at which frame the lemming should be released)

Note that trigger coordinates and sizes should be divisible by 4 when creating styles for engines other than NeoLemmix (including non-Neo CustLemmix).

Also note that the window will overwrite several attributes:
  object_1_start_frame = 1
  object_1_preview_frame = 1
  object_1_trigger_anim = 1

For the window, frame #0 should be the window fully open, frame #1 should be the window fully closed, and the remaining
frames should be the opening sequence. The trigger left and trigger top position can be used to set the coordinates
at which lemmings spawn from it.

Each graphic set must contain at least one object. For practical purposes this would be an exit and a window (or a pre-placed lemming), but in fact, they be anything. However, note that if multi_windows isn't enabled (see in section 4), the second
object in the set is assumed to be a window, overriding whatever other feature you set for it.


TRIGGER EFFECT IDs: ([N] = NeoLemmix only, [ ] = works in both Neo and Traditional)
[ ] 0 - No effect
[ ] 1 - Exit
[ ] 2 - Turn lemmings left
[ ] 3 - Turn lemmings right
[ ] 4 - Trap
[ ] 5 - Water
[ ] 6 - Fire
[ ] 7 - One Way Left
[ ] 8 - One Way Right
[ ] 9 - Steel
[ ] 10 - No blocker area
[N] 11 - Teleporter
[N] 12 - Receiver
[N] 13 - Pre-placed lemming
[N] 14 - Pickup skill
[N] 15 - Locked exit
[N] 16 - Secret area trigger*
[N] 17 - Exit unlock button
[N] 18 - Radiation
[N] 19 - One Way Down
[N] 20 - Updraft
[N] 21 - Splitter
[N] 22 - Slow freeze
[N] 23 - Window
[N] 24 - Triggered harmless animation
[N] 25 - Hint (these are currently neither displayed nor functional)
[N] 26 - No-Splat pad
[N] 27 - Splat pad
[N] 28 - Two-way teleporter
[N] 29 - Single-object teleporter

* Also works in traditional versions of Lemmings Plus II and LPII Bonus Pack


PICKUP SKILL FRAME ORDER:

The correct order for the frames of pickup skills are:
> Blank (already picked up)
> Climber
> Floater
> Bomber
> Blocker
> Builder
> Basher
> Miner
> Digger
> Walker
> Swimmer
> Glider
> Mechanic
> Stoner
> Platformer
> Stacker
> Cloner


TRIGGER SOUND IDs:

(These are copied from ccexplore's documentation on GROUNDxO/VGAGRx format, with the numbers changed from hex to decimal)

0 = no sound
1 = skill select (the sound you get when you click on one of the skill icons at the bottom of the screen)
2 = entrance opening (sounds like "boing")
3 = level intro (the "let's go" sound)
4 = the sound you get when you assign a skill to lemming
5 = the "oh no" sound when a lemming is about to explode
6 = sound effect of the electrode trap and zap trap,
7 = sound effect of the rock squishing trap, pillar squishing trap, and spikes trap
8 = the "aargh" sound when the lemming fall down too far and splatters
9 = sound effect of the rope trap and slicer trap
10 = sound effect when a basher/miner/digger hits steel
11 = (not sure where used in game)
12 = sound effect of a lemming explosion
13 = sound effect of the spinning-trap-of-death, coal pits, and fire shooters (when a lemming touches the object and dies)
14 = sound effect of the 10-ton trap
15 = sound effect of the bear trap
16 = sound effect of a lemming exiting
17 = sound effect of a lemming dropping into water and drowning
18 = sound effect for the last 3 bricks a builder is laying down

Note that some sound effect IDs do not work under Lemmix (whether Neo or traditional).


3) Terrain
LemSet derives most of the information about terrain pieces from the image. The only thing you must do manually is let it know which pieces to consider steel (NeoLemmix feature only). Add the following line to do so:

terrain_#_steel = 1

You do not need to add a terrain_#_steel = 0 for non-steel pieces; LemSet will assume all pieces are not steel unless explicitly told otherwise for a specific piece.


4) Other properties

The style number is optional and is a single line in the following format:

style_number = #

Where # is a number from 0 to 9.

If you enter a style number, LemSet will compile the style as ground#o.dat and vgagr#.dat, where # is
the number you chose. If you do not enter one, it will compile the style to groundXo.dat and vgagrX.dat.


You can mark a style as using the Xmas Palette. Note that this is only for the player's reference;
the defined palette for the style must still be the correct Xmas one rather than the standard one.

xmas_palette = 1


There is a "multi-window" mode, which is a slightly misleading name - what this actually does is mean
that Object #1 of the graphic set is not assumed to be a window.

multi_windows = 1


You can also mark that LemSet should refuse to decompile the compiled style. Please note that this
is a VERY weak protection; it does not encrypt the output in any way, it just sets a flag that tells
LemSet to refuse to decompile it, and as such, can be very easily bypassed by advanced users - but
it should deter n00bs from messing with your style. :P

protect_style = 1




Other notes:
- The maximum number of pieces is 128 terrain and 32 objects in a style for use with NeoLemmix, or 64 terrains and 16 objecs in a style for use with traditional Lemmix.
- The program will stop processing terrain or object data as soon as it encounters a non-existant piece. It won't check if there are more pieces after the gap. So for example, if you have t00.bmp, t01.bmp, t02.bmp and t04.bmp, it will stop after t02.bmp because it can't find t03.bmp, and move on to processing the objects.
- All data in the INI file is *NOT* case-sensitive.
- You *should* be able to compile styles that are in subfolders, simply by including a / when entering a name. EG: if your files are in the "tree" folder and named treestyle.ini, treestyle_t00.bmp, etc, you could enter "tree/treestyle" for the name. You cannot use the generic names (style.ini, t00.bmp, etc) in a subfolder. Also note that this is just my guess based on how the program is coded; the subfolder feature is neither intentional nor officially supported so if an error occurs when using a subfolder that doesn't occur if you don't use one, don't report it.
- As of Update 7, a sample is no longer included. Just get the source files of the LPII or LPIII styles if you need some examples. (As of Update 8, you could also just decompile any style.)